import React from 'react';
import ReactDom from 'react-dom';
import './luopan.scss';
import { api } from 'js/api/api';
import Button from 'views/component/button/button';
import Progress from 'views/component/progress/progress';
import { observer, inject } from 'mobx-react';

@inject('playerStore')
@observer
class Luopan extends React.Component {
    constructor() {
        super()
    }
    componentDidMount() {
    }
    goto = () => {
        api('luopan', () => {
            // api('go', () => {
            //     this.setState({})
            // });
        });
    }
    investigate = () => {
        api('investigate', { mainTaskId: 7 }, (err, data) => {
            if (err === 0) {
                if (data.log) {
                    window.eventHandle.emit('log', data.log);
                }
                this.setState({})
            }
        })
    }
    render() {
        let totalConfig = window.totalConfig, propName = window.propName;
        let luopanConfig = totalConfig.item[203001];
        let player = this.props.playerStore.player;
        let basicInfo = player.basicInfo;
        return <div id="luopan" className="flex-col-hcenter">
            <div className="img"></div>
            <div className="des">{luopanConfig.des}</div>
            {basicInfo.mainTaskId < 8 ? <Progress onEnd={this.investigate}>调查</Progress> :
                <Progress onEnd={this.goto}>开启</Progress>}
            <Button className="luopan-close" onClick={() => { this.props.close() }}>返回</Button>
        </div>
    }
}

export default Luopan;